import 'package:boss/ui/page/takeoutManagement/page/businessSetting/page/timeRange/model/hour_minute.dart';
import 'package:json_annotation/json_annotation.dart';

part 'takeout_business.g.dart';

@JsonSerializable()
class TakeoutBusiness extends Object {

  @JsonKey(name: 'businessStatus')
  int businessStatus;

  @JsonKey(name: 'settingId')
  int settingId;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'takeoutBusinessHours')
  String takeoutBusinessHours;

  @JsonKey(name: 'takeoutSelfMention')
  int takeoutSelfMention;

  @JsonKey(name: 'startMoney')
  int startMoney;

  @JsonKey(name: 'autoReceive', defaultValue: 0)
  int autoReceive;

  String get startTime {
    var time = takeoutBusinessHours.split('-');
    return time[0];
  }

  String get endTime {
    var time = takeoutBusinessHours.split('-');
    return time[1];
  }

  HourMinute get startHourMinute {
    return HourMinute.fromString(startTime);
  }

  HourMinute get endHourMinute {
    return HourMinute.fromString(endTime);
  }

  bool get isTakeoutSelfMention => takeoutSelfMention == 1;

  bool get isBusinessStatus => businessStatus == 1;

  bool get isAutoReceive => autoReceive == 1;

  TakeoutBusiness(this.businessStatus,this.settingId,this.storeId,this.takeoutBusinessHours,this.takeoutSelfMention,);

  factory TakeoutBusiness.fromJson(Map<String, dynamic> srcJson) => _$TakeoutBusinessFromJson(srcJson);

  Map<String, dynamic> toJson() => _$TakeoutBusinessToJson(this);

}


